package io;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos = new FileOutputStream("note3.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bfw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bfw,true);

        System.out.println("开始输入内容,单独输入exit退出");
        Scanner scanner = new Scanner(System.in);
        while (true){
            String s = scanner.nextLine();
            if ("exit".equalsIgnoreCase(s)){
                break;
            }
            pw.println(s);
        }
        pw.close();
        scanner.close();
    }
}
